package com.yc.project.servlet;

import com.google.gson.Gson;
import com.yc.project.dao.FenleiDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "QueryFenleiFoodsServlet", value = "/FenleiFoods.s")
public class QueryFenleiFoodsServlet extends HttpServlet {

    FenleiDao fenleiDao = new FenleiDao();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id=request.getParameter("id");
        List<Map<String,Object>> foods = fenleiDao.selectfenleidish(id);
        String json = new Gson().toJson(foods);
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().append(json);
    }


}
